package eu.winterwheels.enterprise.general;

public class InternalStateMessage {
	private final String DEFAULT_MESSAGE = "Caution. This State Message has not been initialized.";

	private Boolean healthy;
	private String message = DEFAULT_MESSAGE;
	private String description = "";

	public InternalStateMessage(boolean healthy, String message, String description) {
		setHealthy(healthy);
		setMessage(message);
		setDescription(description);
	}

	public InternalStateMessage(boolean healthy, String message) {
		setHealthy(healthy);
		setMessage(message);
	}

	public boolean isHealthy() throws IllegalStateException {
		if (healthy == null)
			throw new IllegalStateException(DEFAULT_MESSAGE
					+ " Health state is null.");
		return healthy.booleanValue();
	}

	public void setHealthy(boolean healthy) {
		this.healthy = healthy;
	}

	public String getMessage() throws IllegalStateException {
		if (message.equals(DEFAULT_MESSAGE))
			throw new IllegalStateException(DEFAULT_MESSAGE
					+ " Text Message is not set.");
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
